package com.zhiwei.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhiwei.mapper.RepositoryMapper;
import com.zhiwei.pojo.Repository;
import com.zhiwei.pojo.UserRequests;
import com.zhiwei.vo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

@Service
public class RepositoryServiceImpl implements RepositoryService{
    @Autowired
    private RepositoryMapper repositoryMapper;

    @Override
    public List<Repository> getResptList() {
        QueryWrapper<Repository> repositoryQueryWrapper = new QueryWrapper<>();
        repositoryQueryWrapper.eq("delete_flag",false);
        List<Repository> requests = repositoryMapper.selectList(repositoryQueryWrapper);
        return requests;
    }

    @Override
    public int newRepos(Repository repository) {
        repository.setStatus(false);
        int insert = repositoryMapper.insert(repository);
        return insert;
    }

    @Override
    public int deleteRepos(Integer id) {
        Repository repository = new Repository();
        repository.setId(id).setDeleteFlag(true);
        return repositoryMapper.updateById(repository);
    }

    @Override
    public int updateRepos(Repository repository) {

        return 0;
    }
}
